
var bdPass=bdPass||{};
bdPass.weakpwdCallback=function(a){
	if(a.errno+""=="0"){
		bdPass.pwdHandler[a.pwdWeak+""]()
		}
	};
bdPass.passwordOk = false;
bdPass.pwdHandler=(function(){
	var f=document.getElementById("pwd_weak_word");
	var e=document.getElementById("pwd_weakness");
	var g=$("#password_level_color_red");
	var d=$("#password_level_color_orange");  //无
	var a=$("#password_level_color_green");   //无
	var c=$("#error_password");
	var b=function(){
		g.hide();
		d.hide();
		a.hide()
	};
	return{
		"0":function(){
			f.innerHTML="强";
			f.className="strong_word";
			e.className="pwd_stren_inner strength_strong";
			c.hide();
			bdPass.passwordOk=true
			},
		"1":function(){
			f.innerHTML="中";
			f.className="middle_word";
			e.className="pwd_stren_inner strength_middle";
			c.text("密码比较简单，安全等级低，建议更换更复杂的密码").css("display","inline");
			bdPass.passwordOk=true
			},
		"2":function(){
			f.innerHTML="弱";
			f.className="weak_word";
			e.className="pwd_stren_inner strength_weak";
			c.text("您的密码结构太过简单，请更换更复杂的密码，否则无法注册成功").css("display","inline");
			bdPass.passwordOk=false
			},
		empty:function(){
			f.innerHTML="弱";
			f.className="weak_word";
			e.className="pwd_stren_inner strength_weak";
			c.text("请输入密码").css("display","inline");
			bdPass.passwordOk=false
		},tooLongOrTooShort:function(){
			f.innerHTML="弱";
			f.className="weak_word";
			e.className="pwd_stren_inner strength_weak";
			c.text("密码最少6个字符，最长不得超过14个字符").css("display","inline");
			bdPass.passwordOk=false
		},
		charError:function(){
			f.innerHTML="弱";
			f.className="weak_word";
			e.className="pwd_stren_inner strength_weak";
			c.text("密码由数字，字母和符号组成，字母区分大小写").css("display","inline");
			bdPass.passwordOk=false
			}
		}
	})();
$(function(){
	var c = $("#password");
	var b = function(){
		var e = c.val(),d = e.length;
		if(d==0){
			bdPass.pwdHandler.empty()
		}else{
			if(d<6||d>14){
				bdPass.pwdHandler.tooLongOrTooShort()
			}else{
			if(/^([0-9a-zA-Z\_`!~@#$%^*+=,.?;'":)(}{/\\\|<>&\[\-]|\])+$/.test(e)){
				$.getScript("https://passport.baidu.com/v2/?regpwdcheck&fromreg=1&callback=bdPass.weakpwdCallback&password="+encodeURIComponent(e))
			}else{
				bdPass.pwdHandler.charError()
			}
		}
	}
};
c.keyup(b);
c[0].focus();
var a=function(){
	var d=$("#error_repassword");
	if($("#re_password").val()==c.val()){
		d.hide();
		return true
	}else{
		d.css("display","inline");
		return false
	}
};
$("#re_password").blur(a);
$("#form").bind("submit",function(){
							b();
							return bdPass.passwordOk&&a()
							})
});
